package network

import (
	"fmt"
	"gomir/network/proto/client"
	"gomir/network/proto/server"
	"reflect"
)

// 协议必须实现该接口才能注册
type Protocol interface {
	GetId() int
}

// 协议元信息
type ProtoMeta struct {
	ID   int
	Name string
	Type reflect.Type
	New  func() Protocol
}

// 创建meta类型的实例
func (meta *ProtoMeta) NewProto() Protocol {
	if meta.New != nil {
		return meta.New()
	}
	//if meta.Type != nil {
	//	return reflect.New(meta.Type).Interface().(Protocol)
	//}
	return nil
}

var (
	metaByType = map[reflect.Type]*ProtoMeta{}
	metaByID   []*ProtoMeta
)

const MAX_PROTOCOL_COUNT = server.MAX_PROTOCOL

func init() {
	metaByID = make([]*ProtoMeta, MAX_PROTOCOL_COUNT)
	RegisterClientProtocol()
	fmt.Println("注册客户端协议:", client.MAX_PROTOCOL-1000)
	RegisterServerProtocol()
	fmt.Println("注册服务端协议:", server.MAX_PROTOCOL-2000)
}

func RegisterProtocol(id int, t reflect.Type, f func() Protocol) {
	// 参数必须使用指针如reflect.TypeOf((*client.ClientVersion)(nil))
	if t.Kind() != reflect.Ptr {
		panic("RegisterProtocol must use reflect.Ptr")
	}
	// 注册时, 统一为非指针类型
	elem := t.Elem()
	// 确保注册的协议实现了Protocol接口
	iproto := reflect.TypeOf((*Protocol)(nil)).Elem()
	if !t.Implements(iproto) {
		panic(fmt.Sprintln(elem.Name(), " must implements Protocol{}"))
	}

	meta := &ProtoMeta{
		ID:   id,
		Type: elem,
		Name: elem.Name(),
		New:  f,
	}

	if ok := metaByID[meta.ID]; ok != nil {
		panic(fmt.Sprintf("Protocol register by type: %d name: %s", meta.ID, meta.Type.Name()))
	} else {
		metaByID[meta.ID] = meta
	}

	metaByID[id] = meta

	if _, ok := metaByType[meta.Type]; ok {
		panic(fmt.Sprintf("Protocol register by type: %d name: %s", meta.ID, meta.Type.Name()))
	} else {
		metaByType[meta.Type] = meta
	}
}

// 根据类型获取协议元信息
func ProtoMetaByType(t reflect.Type) *ProtoMeta {
	if t == nil {
		return nil
	}
	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}
	if v, ok := metaByType[t]; ok {
		return v
	}
	return nil
}

// 根据对象获取协议元信息
func ProtoMetaByMsg(p Protocol) *ProtoMeta {
	if p == nil {
		return nil
	}
	return ProtoMetaByID(p.GetId())
	//return ProtoMetaByType(reflect.TypeOf(p))
}

// 根据id获取协议元信息
func ProtoMetaByID(id int) *ProtoMeta {
	if id >= MAX_PROTOCOL_COUNT {
		return nil
	}
	return metaByID[id]
}

func RegisterClientProtocol() {
	RegisterProtocol(client.CLIENT_VERSION, reflect.TypeOf((*client.ClientVersion)(nil)), func() Protocol { return &client.ClientVersion{} })
	RegisterProtocol(client.DISCONNECT, reflect.TypeOf((*client.Disconnect)(nil)), func() Protocol { return &client.Disconnect{} })
	RegisterProtocol(client.KEEP_ALIVE, reflect.TypeOf((*client.KeepAlive)(nil)), func() Protocol { return &client.KeepAlive{} })
	RegisterProtocol(client.NEW_ACCOUNT, reflect.TypeOf((*client.NewAccount)(nil)), func() Protocol { return &client.NewAccount{} })
	RegisterProtocol(client.CHANGE_PASSWORD, reflect.TypeOf((*client.ChangePassword)(nil)), func() Protocol { return &client.ChangePassword{} })
	RegisterProtocol(client.LOGIN, reflect.TypeOf((*client.Login)(nil)), func() Protocol { return &client.Login{} })
	RegisterProtocol(client.NEW_CHARACTER, reflect.TypeOf((*client.NewCharacter)(nil)), func() Protocol { return &client.NewCharacter{} })
	RegisterProtocol(client.DELETE_CHARACTER, reflect.TypeOf((*client.DeleteCharacter)(nil)), func() Protocol { return &client.DeleteCharacter{} })
	RegisterProtocol(client.START_GAME, reflect.TypeOf((*client.StartGame)(nil)), func() Protocol { return &client.StartGame{} })
	RegisterProtocol(client.LOG_OUT, reflect.TypeOf((*client.LogOut)(nil)), func() Protocol { return &client.LogOut{} })
	RegisterProtocol(client.TURN, reflect.TypeOf((*client.Turn)(nil)), func() Protocol { return &client.Turn{} })
	RegisterProtocol(client.WALK, reflect.TypeOf((*client.Walk)(nil)), func() Protocol { return &client.Walk{} })
	RegisterProtocol(client.RUN, reflect.TypeOf((*client.Run)(nil)), func() Protocol { return &client.Run{} })
	RegisterProtocol(client.CHAT, reflect.TypeOf((*client.Chat)(nil)), func() Protocol { return &client.Chat{} })
	RegisterProtocol(client.MOVE_ITEM, reflect.TypeOf((*client.MoveItem)(nil)), func() Protocol { return &client.MoveItem{} })
	RegisterProtocol(client.STORE_ITEM, reflect.TypeOf((*client.StoreItem)(nil)), func() Protocol { return &client.StoreItem{} })
	RegisterProtocol(client.TAKE_BACK_ITEM, reflect.TypeOf((*client.TakeBackItem)(nil)), func() Protocol { return &client.TakeBackItem{} })
	RegisterProtocol(client.MERGE_ITEM, reflect.TypeOf((*client.MergeItem)(nil)), func() Protocol { return &client.MergeItem{} })
	RegisterProtocol(client.EQUIP_ITEM, reflect.TypeOf((*client.EquipItem)(nil)), func() Protocol { return &client.EquipItem{} })
	RegisterProtocol(client.REMOVE_ITEM, reflect.TypeOf((*client.RemoveItem)(nil)), func() Protocol { return &client.RemoveItem{} })
	RegisterProtocol(client.REMOVE_SLOT_ITEM, reflect.TypeOf((*client.RemoveSlotItem)(nil)), func() Protocol { return &client.RemoveSlotItem{} })
	RegisterProtocol(client.SPLIT_ITEM, reflect.TypeOf((*client.SplitItem)(nil)), func() Protocol { return &client.SplitItem{} })
	RegisterProtocol(client.USE_ITEM, reflect.TypeOf((*client.UseItem)(nil)), func() Protocol { return &client.UseItem{} })
	RegisterProtocol(client.DROP_ITEM, reflect.TypeOf((*client.DropItem)(nil)), func() Protocol { return &client.DropItem{} })
	RegisterProtocol(client.DEPOSIT_REFINE_ITEM, reflect.TypeOf((*client.DepositRefineItem)(nil)), func() Protocol { return &client.DepositRefineItem{} })
	RegisterProtocol(client.RETRIEVE_REFINE_ITEM, reflect.TypeOf((*client.RetrieveRefineItem)(nil)), func() Protocol { return &client.RetrieveRefineItem{} })
	RegisterProtocol(client.REFINE_CANCEL, reflect.TypeOf((*client.RefineCancel)(nil)), func() Protocol { return &client.RefineCancel{} })
	RegisterProtocol(client.REFINE_ITEM, reflect.TypeOf((*client.RefineItem)(nil)), func() Protocol { return &client.RefineItem{} })
	RegisterProtocol(client.CHECK_REFINE, reflect.TypeOf((*client.CheckRefine)(nil)), func() Protocol { return &client.CheckRefine{} })
	RegisterProtocol(client.REPLACE_WED_RING, reflect.TypeOf((*client.ReplaceWedRing)(nil)), func() Protocol { return &client.ReplaceWedRing{} })
	RegisterProtocol(client.DEPOSIT_TRADE_ITEM, reflect.TypeOf((*client.DepositTradeItem)(nil)), func() Protocol { return &client.DepositTradeItem{} })
	RegisterProtocol(client.RETRIEVE_TRADE_ITEM, reflect.TypeOf((*client.RetrieveTradeItem)(nil)), func() Protocol { return &client.RetrieveTradeItem{} })
	RegisterProtocol(client.DROP_GOLD, reflect.TypeOf((*client.DropGold)(nil)), func() Protocol { return &client.DropGold{} })
	RegisterProtocol(client.PICK_UP, reflect.TypeOf((*client.PickUp)(nil)), func() Protocol { return &client.PickUp{} })
	RegisterProtocol(client.INSPECT, reflect.TypeOf((*client.Inspect)(nil)), func() Protocol { return &client.Inspect{} })
	RegisterProtocol(client.CHANGE_A_MODE, reflect.TypeOf((*client.ChangeAMode)(nil)), func() Protocol { return &client.ChangeAMode{} })
	RegisterProtocol(client.CHANGE_P_MODE, reflect.TypeOf((*client.ChangePMode)(nil)), func() Protocol { return &client.ChangePMode{} })
	RegisterProtocol(client.CHANGE_TRADE, reflect.TypeOf((*client.ChangeTrade)(nil)), func() Protocol { return &client.ChangeTrade{} })
	RegisterProtocol(client.ATTACK, reflect.TypeOf((*client.Attack)(nil)), func() Protocol { return &client.Attack{} })
	RegisterProtocol(client.RANGE_ATTACK, reflect.TypeOf((*client.RangeAttack)(nil)), func() Protocol { return &client.RangeAttack{} })
	RegisterProtocol(client.HARVEST, reflect.TypeOf((*client.Harvest)(nil)), func() Protocol { return &client.Harvest{} })
	RegisterProtocol(client.CALL_NPC, reflect.TypeOf((*client.CallNPC)(nil)), func() Protocol { return &client.CallNPC{} })
	RegisterProtocol(client.TALK_MONSTER_NPC, reflect.TypeOf((*client.TalkMonsterNPC)(nil)), func() Protocol { return &client.TalkMonsterNPC{} })
	RegisterProtocol(client.BUY_ITEM, reflect.TypeOf((*client.BuyItem)(nil)), func() Protocol { return &client.BuyItem{} })
	RegisterProtocol(client.SELL_ITEM, reflect.TypeOf((*client.SellItem)(nil)), func() Protocol { return &client.SellItem{} })
	RegisterProtocol(client.CRAFT_ITEM, reflect.TypeOf((*client.CraftItem)(nil)), func() Protocol { return &client.CraftItem{} })
	RegisterProtocol(client.REPAIR_ITEM, reflect.TypeOf((*client.RepairItem)(nil)), func() Protocol { return &client.RepairItem{} })
	RegisterProtocol(client.BUY_ITEM_BACK, reflect.TypeOf((*client.BuyItemBack)(nil)), func() Protocol { return &client.BuyItemBack{} })
	RegisterProtocol(client.S_REPAIR_ITEM, reflect.TypeOf((*client.SRepairItem)(nil)), func() Protocol { return &client.SRepairItem{} })
	RegisterProtocol(client.MAGIC_KEY, reflect.TypeOf((*client.MagicKey)(nil)), func() Protocol { return &client.MagicKey{} })
	RegisterProtocol(client.MAGIC, reflect.TypeOf((*client.Magic)(nil)), func() Protocol { return &client.Magic{} })
	RegisterProtocol(client.SWITCH_GROUP, reflect.TypeOf((*client.SwitchGroup)(nil)), func() Protocol { return &client.SwitchGroup{} })
	RegisterProtocol(client.ADD_MEMBER, reflect.TypeOf((*client.AddMember)(nil)), func() Protocol { return &client.AddMember{} })
	RegisterProtocol(client.DEL_MEMBER, reflect.TypeOf((*client.DelMember)(nil)), func() Protocol { return &client.DelMember{} })
	RegisterProtocol(client.GROUP_INVITE, reflect.TypeOf((*client.GroupInvite)(nil)), func() Protocol { return &client.GroupInvite{} })
	RegisterProtocol(client.TOWN_REVIVE, reflect.TypeOf((*client.TownRevive)(nil)), func() Protocol { return &client.TownRevive{} })
	RegisterProtocol(client.SPELL_TOGGLE, reflect.TypeOf((*client.SpellToggle)(nil)), func() Protocol { return &client.SpellToggle{} })
	RegisterProtocol(client.CONSIGN_ITEM, reflect.TypeOf((*client.ConsignItem)(nil)), func() Protocol { return &client.ConsignItem{} })
	RegisterProtocol(client.MARKET_SEARCH, reflect.TypeOf((*client.MarketSearch)(nil)), func() Protocol { return &client.MarketSearch{} })
	RegisterProtocol(client.MARKET_REFRESH, reflect.TypeOf((*client.MarketRefresh)(nil)), func() Protocol { return &client.MarketRefresh{} })
	RegisterProtocol(client.MARKET_PAGE, reflect.TypeOf((*client.MarketPage)(nil)), func() Protocol { return &client.MarketPage{} })
	RegisterProtocol(client.MARKET_BUY, reflect.TypeOf((*client.MarketBuy)(nil)), func() Protocol { return &client.MarketBuy{} })
	RegisterProtocol(client.MARKET_GET_BACK, reflect.TypeOf((*client.MarketGetBack)(nil)), func() Protocol { return &client.MarketGetBack{} })
	RegisterProtocol(client.REQUEST_USER_NAME, reflect.TypeOf((*client.RequestUserName)(nil)), func() Protocol { return &client.RequestUserName{} })
	RegisterProtocol(client.REQUEST_CHAT_ITEM, reflect.TypeOf((*client.RequestChatItem)(nil)), func() Protocol { return &client.RequestChatItem{} })
	RegisterProtocol(client.EDIT_GUILD_MEMBER, reflect.TypeOf((*client.EditGuildMember)(nil)), func() Protocol { return &client.EditGuildMember{} })
	RegisterProtocol(client.EDIT_GUILD_NOTICE, reflect.TypeOf((*client.EditGuildNotice)(nil)), func() Protocol { return &client.EditGuildNotice{} })
	RegisterProtocol(client.GUILD_INVITE, reflect.TypeOf((*client.GuildInvite)(nil)), func() Protocol { return &client.GuildInvite{} })
	RegisterProtocol(client.GUILD_NAME_RETURN, reflect.TypeOf((*client.GuildNameReturn)(nil)), func() Protocol { return &client.GuildNameReturn{} })
	RegisterProtocol(client.REQUEST_GUILD_INFO, reflect.TypeOf((*client.RequestGuildInfo)(nil)), func() Protocol { return &client.RequestGuildInfo{} })
	RegisterProtocol(client.GUILD_STORAGE_GOLD_CHANGE, reflect.TypeOf((*client.GuildStorageGoldChange)(nil)), func() Protocol { return &client.GuildStorageGoldChange{} })
	RegisterProtocol(client.GUILD_STORAGE_ITEM_CHANGE, reflect.TypeOf((*client.GuildStorageItemChange)(nil)), func() Protocol { return &client.GuildStorageItemChange{} })
	RegisterProtocol(client.GUILD_WAR_RETURN, reflect.TypeOf((*client.GuildWarReturn)(nil)), func() Protocol { return &client.GuildWarReturn{} })
	RegisterProtocol(client.MARRIAGE_REQUEST, reflect.TypeOf((*client.MarriageRequest)(nil)), func() Protocol { return &client.MarriageRequest{} })
	RegisterProtocol(client.MARRIAGE_REPLY, reflect.TypeOf((*client.MarriageReply)(nil)), func() Protocol { return &client.MarriageReply{} })
	RegisterProtocol(client.CHANGE_MARRIAGE, reflect.TypeOf((*client.ChangeMarriage)(nil)), func() Protocol { return &client.ChangeMarriage{} })
	RegisterProtocol(client.DIVORCE_REQUEST, reflect.TypeOf((*client.DivorceRequest)(nil)), func() Protocol { return &client.DivorceRequest{} })
	RegisterProtocol(client.DIVORCE_REPLY, reflect.TypeOf((*client.DivorceReply)(nil)), func() Protocol { return &client.DivorceReply{} })
	RegisterProtocol(client.ADD_MENTOR, reflect.TypeOf((*client.AddMentor)(nil)), func() Protocol { return &client.AddMentor{} })
	RegisterProtocol(client.MENTOR_REPLY, reflect.TypeOf((*client.MentorReply)(nil)), func() Protocol { return &client.MentorReply{} })
	RegisterProtocol(client.ALLOW_MENTOR, reflect.TypeOf((*client.AllowMentor)(nil)), func() Protocol { return &client.AllowMentor{} })
	RegisterProtocol(client.CANCEL_MENTOR, reflect.TypeOf((*client.CancelMentor)(nil)), func() Protocol { return &client.CancelMentor{} })
	RegisterProtocol(client.TRADE_REQUEST, reflect.TypeOf((*client.TradeRequest)(nil)), func() Protocol { return &client.TradeRequest{} })
	RegisterProtocol(client.TRADE_REPLY, reflect.TypeOf((*client.TradeReply)(nil)), func() Protocol { return &client.TradeReply{} })
	RegisterProtocol(client.TRADE_GOLD, reflect.TypeOf((*client.TradeGold)(nil)), func() Protocol { return &client.TradeGold{} })
	RegisterProtocol(client.TRADE_CONFIRM, reflect.TypeOf((*client.TradeConfirm)(nil)), func() Protocol { return &client.TradeConfirm{} })
	RegisterProtocol(client.TRADE_CANCEL, reflect.TypeOf((*client.TradeCancel)(nil)), func() Protocol { return &client.TradeCancel{} })
	RegisterProtocol(client.EQUIP_SLOT_ITEM, reflect.TypeOf((*client.EquipSlotItem)(nil)), func() Protocol { return &client.EquipSlotItem{} })
	RegisterProtocol(client.FISHING_CAST, reflect.TypeOf((*client.FishingCast)(nil)), func() Protocol { return &client.FishingCast{} })
	RegisterProtocol(client.FISHING_CHANGE_AUTOCAST, reflect.TypeOf((*client.FishingChangeAutocast)(nil)), func() Protocol { return &client.FishingChangeAutocast{} })
	RegisterProtocol(client.ACCEPT_QUEST, reflect.TypeOf((*client.AcceptQuest)(nil)), func() Protocol { return &client.AcceptQuest{} })
	RegisterProtocol(client.FINISH_QUEST, reflect.TypeOf((*client.FinishQuest)(nil)), func() Protocol { return &client.FinishQuest{} })
	RegisterProtocol(client.ABANDON_QUEST, reflect.TypeOf((*client.AbandonQuest)(nil)), func() Protocol { return &client.AbandonQuest{} })
	RegisterProtocol(client.SHARE_QUEST, reflect.TypeOf((*client.ShareQuest)(nil)), func() Protocol { return &client.ShareQuest{} })
	RegisterProtocol(client.ACCEPT_REINCARNATION, reflect.TypeOf((*client.AcceptReincarnation)(nil)), func() Protocol { return &client.AcceptReincarnation{} })
	RegisterProtocol(client.CANCEL_REINCARNATION, reflect.TypeOf((*client.CancelReincarnation)(nil)), func() Protocol { return &client.CancelReincarnation{} })
	RegisterProtocol(client.COMBINE_ITEM, reflect.TypeOf((*client.CombineItem)(nil)), func() Protocol { return &client.CombineItem{} })
	RegisterProtocol(client.SET_CONCENTRATION, reflect.TypeOf((*client.SetConcentration)(nil)), func() Protocol { return &client.SetConcentration{} })
	RegisterProtocol(client.AWAKENING_NEED_MATERIALS, reflect.TypeOf((*client.AwakeningNeedMaterials)(nil)), func() Protocol { return &client.AwakeningNeedMaterials{} })
	RegisterProtocol(client.AWAKENING_LOCKED_ITEM, reflect.TypeOf((*client.AwakeningLockedItem)(nil)), func() Protocol { return &client.AwakeningLockedItem{} })
	RegisterProtocol(client.AWAKENING, reflect.TypeOf((*client.Awakening)(nil)), func() Protocol { return &client.Awakening{} })
	RegisterProtocol(client.DISASSEMBLE_ITEM, reflect.TypeOf((*client.DisassembleItem)(nil)), func() Protocol { return &client.DisassembleItem{} })
	RegisterProtocol(client.DOWNGRADE_AWAKENING, reflect.TypeOf((*client.DowngradeAwakening)(nil)), func() Protocol { return &client.DowngradeAwakening{} })
	RegisterProtocol(client.RESET_ADDED_ITEM, reflect.TypeOf((*client.ResetAddedItem)(nil)), func() Protocol { return &client.ResetAddedItem{} })
	RegisterProtocol(client.SEND_MAIL, reflect.TypeOf((*client.SendMail)(nil)), func() Protocol { return &client.SendMail{} })
	RegisterProtocol(client.READ_MAIL, reflect.TypeOf((*client.ReadMail)(nil)), func() Protocol { return &client.ReadMail{} })
	RegisterProtocol(client.COLLECT_PARCEL, reflect.TypeOf((*client.CollectParcel)(nil)), func() Protocol { return &client.CollectParcel{} })
	RegisterProtocol(client.DELETE_MAIL, reflect.TypeOf((*client.DeleteMail)(nil)), func() Protocol { return &client.DeleteMail{} })
	RegisterProtocol(client.LOCK_MAIL, reflect.TypeOf((*client.LockMail)(nil)), func() Protocol { return &client.LockMail{} })
	RegisterProtocol(client.MAIL_LOCKED_ITEM, reflect.TypeOf((*client.MailLockedItem)(nil)), func() Protocol { return &client.MailLockedItem{} })
	RegisterProtocol(client.MAIL_COST, reflect.TypeOf((*client.MailCost)(nil)), func() Protocol { return &client.MailCost{} })
	RegisterProtocol(client.UPDATE_INTELLIGENT_CREATURE, reflect.TypeOf((*client.UpdateIntelligentCreature)(nil)), func() Protocol { return &client.UpdateIntelligentCreature{} })
	RegisterProtocol(client.INTELLIGENT_CREATURE_PICKUP, reflect.TypeOf((*client.IntelligentCreaturePickup)(nil)), func() Protocol { return &client.IntelligentCreaturePickup{} })
	RegisterProtocol(client.ADD_FRIEND, reflect.TypeOf((*client.AddFriend)(nil)), func() Protocol { return &client.AddFriend{} })
	RegisterProtocol(client.REMOVE_FRIEND, reflect.TypeOf((*client.RemoveFriend)(nil)), func() Protocol { return &client.RemoveFriend{} })
	RegisterProtocol(client.REFRESH_FRIENDS, reflect.TypeOf((*client.RefreshFriends)(nil)), func() Protocol { return &client.RefreshFriends{} })
	RegisterProtocol(client.ADD_MEMO, reflect.TypeOf((*client.AddMemo)(nil)), func() Protocol { return &client.AddMemo{} })
	RegisterProtocol(client.GUILD_BUFF_UPDATE, reflect.TypeOf((*client.GuildBuffUpdate)(nil)), func() Protocol { return &client.GuildBuffUpdate{} })
	RegisterProtocol(client.NPC_CONFIRM_INPUT, reflect.TypeOf((*client.NPCConfirmInput)(nil)), func() Protocol { return &client.NPCConfirmInput{} })
	RegisterProtocol(client.GAMESHOP_BUY, reflect.TypeOf((*client.GameshopBuy)(nil)), func() Protocol { return &client.GameshopBuy{} })
	RegisterProtocol(client.REPORT_ISSUE, reflect.TypeOf((*client.ReportIssue)(nil)), func() Protocol { return &client.ReportIssue{} })
	RegisterProtocol(client.GET_RANKING, reflect.TypeOf((*client.GetRanking)(nil)), func() Protocol { return &client.GetRanking{} })
	RegisterProtocol(client.OPENDOOR, reflect.TypeOf((*client.Opendoor)(nil)), func() Protocol { return &client.Opendoor{} })
	RegisterProtocol(client.GET_RENTED_ITEMS, reflect.TypeOf((*client.GetRentedItems)(nil)), func() Protocol { return &client.GetRentedItems{} })
	RegisterProtocol(client.ITEM_RENTAL_REQUEST, reflect.TypeOf((*client.ItemRentalRequest)(nil)), func() Protocol { return &client.ItemRentalRequest{} })
	RegisterProtocol(client.ITEM_RENTAL_FEE, reflect.TypeOf((*client.ItemRentalFee)(nil)), func() Protocol { return &client.ItemRentalFee{} })
	RegisterProtocol(client.ITEM_RENTAL_PERIOD, reflect.TypeOf((*client.ItemRentalPeriod)(nil)), func() Protocol { return &client.ItemRentalPeriod{} })
	RegisterProtocol(client.DEPOSIT_RENTAL_ITEM, reflect.TypeOf((*client.DepositRentalItem)(nil)), func() Protocol { return &client.DepositRentalItem{} })
	RegisterProtocol(client.RETRIEVE_RENTAL_ITEM, reflect.TypeOf((*client.RetrieveRentalItem)(nil)), func() Protocol { return &client.RetrieveRentalItem{} })
	RegisterProtocol(client.CANCEL_ITEM_RENTAL, reflect.TypeOf((*client.CancelItemRental)(nil)), func() Protocol { return &client.CancelItemRental{} })
	RegisterProtocol(client.ITEM_RENTAL_LOCK_FEE, reflect.TypeOf((*client.ItemRentalLockFee)(nil)), func() Protocol { return &client.ItemRentalLockFee{} })
	RegisterProtocol(client.ITEM_RENTAL_LOCK_ITEM, reflect.TypeOf((*client.ItemRentalLockItem)(nil)), func() Protocol { return &client.ItemRentalLockItem{} })
	RegisterProtocol(client.CONFIRM_ITEM_RENTAL, reflect.TypeOf((*client.ConfirmItemRental)(nil)), func() Protocol { return &client.ConfirmItemRental{} })
}
func RegisterServerProtocol() {
	RegisterProtocol(server.CONNECTED, reflect.TypeOf((*server.Connected)(nil)), func() Protocol { return &server.Connected{} })
	RegisterProtocol(server.CLIENT_VERSION, reflect.TypeOf((*server.ClientVersion)(nil)), func() Protocol { return &server.ClientVersion{} })
	RegisterProtocol(server.DISCONNECT, reflect.TypeOf((*server.Disconnect)(nil)), func() Protocol { return &server.Disconnect{} })
	RegisterProtocol(server.KEEP_ALIVE, reflect.TypeOf((*server.KeepAlive)(nil)), func() Protocol { return &server.KeepAlive{} })
	RegisterProtocol(server.NEW_ACCOUNT, reflect.TypeOf((*server.NewAccount)(nil)), func() Protocol { return &server.NewAccount{} })
	RegisterProtocol(server.CHANGE_PASSWORD, reflect.TypeOf((*server.ChangePassword)(nil)), func() Protocol { return &server.ChangePassword{} })
	RegisterProtocol(server.CHANGE_PASSWORD_BANNED, reflect.TypeOf((*server.ChangePasswordBanned)(nil)), func() Protocol { return &server.ChangePasswordBanned{} })
	RegisterProtocol(server.LOGIN, reflect.TypeOf((*server.Login)(nil)), func() Protocol { return &server.Login{} })
	RegisterProtocol(server.LOGIN_BANNED, reflect.TypeOf((*server.LoginBanned)(nil)), func() Protocol { return &server.LoginBanned{} })
	RegisterProtocol(server.LOGIN_SUCCESS, reflect.TypeOf((*server.LoginSuccess)(nil)), func() Protocol { return &server.LoginSuccess{} })
	RegisterProtocol(server.NEW_CHARACTER, reflect.TypeOf((*server.NewCharacter)(nil)), func() Protocol { return &server.NewCharacter{} })
	RegisterProtocol(server.NEW_CHARACTER_SUCCESS, reflect.TypeOf((*server.NewCharacterSuccess)(nil)), func() Protocol { return &server.NewCharacterSuccess{} })
	RegisterProtocol(server.DELETE_CHARACTER, reflect.TypeOf((*server.DeleteCharacter)(nil)), func() Protocol { return &server.DeleteCharacter{} })
	RegisterProtocol(server.DELETE_CHARACTER_SUCCESS, reflect.TypeOf((*server.DeleteCharacterSuccess)(nil)), func() Protocol { return &server.DeleteCharacterSuccess{} })
	RegisterProtocol(server.START_GAME, reflect.TypeOf((*server.StartGame)(nil)), func() Protocol { return &server.StartGame{} })
	RegisterProtocol(server.START_GAME_BANNED, reflect.TypeOf((*server.StartGameBanned)(nil)), func() Protocol { return &server.StartGameBanned{} })
	RegisterProtocol(server.START_GAME_DELAY, reflect.TypeOf((*server.StartGameDelay)(nil)), func() Protocol { return &server.StartGameDelay{} })
	RegisterProtocol(server.MAP_INFORMATION, reflect.TypeOf((*server.MapInformation)(nil)), func() Protocol { return &server.MapInformation{} })
	RegisterProtocol(server.USER_INFORMATION, reflect.TypeOf((*server.UserInformation)(nil)), func() Protocol { return &server.UserInformation{} })
	RegisterProtocol(server.USER_LOCATION, reflect.TypeOf((*server.UserLocation)(nil)), func() Protocol { return &server.UserLocation{} })
	RegisterProtocol(server.OBJECT_PLAYER, reflect.TypeOf((*server.ObjectPlayer)(nil)), func() Protocol { return &server.ObjectPlayer{} })
	RegisterProtocol(server.OBJECT_REMOVE, reflect.TypeOf((*server.ObjectRemove)(nil)), func() Protocol { return &server.ObjectRemove{} })
	RegisterProtocol(server.OBJECT_TURN, reflect.TypeOf((*server.ObjectTurn)(nil)), func() Protocol { return &server.ObjectTurn{} })
	RegisterProtocol(server.OBJECT_WALK, reflect.TypeOf((*server.ObjectWalk)(nil)), func() Protocol { return &server.ObjectWalk{} })
	RegisterProtocol(server.OBJECT_RUN, reflect.TypeOf((*server.ObjectRun)(nil)), func() Protocol { return &server.ObjectRun{} })
	RegisterProtocol(server.CHAT, reflect.TypeOf((*server.Chat)(nil)), func() Protocol { return &server.Chat{} })
	RegisterProtocol(server.OBJECT_CHAT, reflect.TypeOf((*server.ObjectChat)(nil)), func() Protocol { return &server.ObjectChat{} })
	RegisterProtocol(server.NEW_ITEM_INFO, reflect.TypeOf((*server.NewItemInfo)(nil)), func() Protocol { return &server.NewItemInfo{} })
	RegisterProtocol(server.MOVE_ITEM, reflect.TypeOf((*server.MoveItem)(nil)), func() Protocol { return &server.MoveItem{} })
	RegisterProtocol(server.EQUIP_ITEM, reflect.TypeOf((*server.EquipItem)(nil)), func() Protocol { return &server.EquipItem{} })
	RegisterProtocol(server.MERGE_ITEM, reflect.TypeOf((*server.MergeItem)(nil)), func() Protocol { return &server.MergeItem{} })
	RegisterProtocol(server.REMOVE_ITEM, reflect.TypeOf((*server.RemoveItem)(nil)), func() Protocol { return &server.RemoveItem{} })
	RegisterProtocol(server.REMOVE_SLOT_ITEM, reflect.TypeOf((*server.RemoveSlotItem)(nil)), func() Protocol { return &server.RemoveSlotItem{} })
	RegisterProtocol(server.TAKE_BACK_ITEM, reflect.TypeOf((*server.TakeBackItem)(nil)), func() Protocol { return &server.TakeBackItem{} })
	RegisterProtocol(server.STORE_ITEM, reflect.TypeOf((*server.StoreItem)(nil)), func() Protocol { return &server.StoreItem{} })
	RegisterProtocol(server.SPLIT_ITEM, reflect.TypeOf((*server.SplitItem)(nil)), func() Protocol { return &server.SplitItem{} })
	RegisterProtocol(server.SPLIT_ITEM1, reflect.TypeOf((*server.SplitItem1)(nil)), func() Protocol { return &server.SplitItem1{} })
	RegisterProtocol(server.DEPOSIT_REFINE_ITEM, reflect.TypeOf((*server.DepositRefineItem)(nil)), func() Protocol { return &server.DepositRefineItem{} })
	RegisterProtocol(server.RETRIEVE_REFINE_ITEM, reflect.TypeOf((*server.RetrieveRefineItem)(nil)), func() Protocol { return &server.RetrieveRefineItem{} })
	RegisterProtocol(server.REFINE_CANCEL, reflect.TypeOf((*server.RefineCancel)(nil)), func() Protocol { return &server.RefineCancel{} })
	RegisterProtocol(server.REFINE_ITEM, reflect.TypeOf((*server.RefineItem)(nil)), func() Protocol { return &server.RefineItem{} })
	RegisterProtocol(server.DEPOSIT_TRADE_ITEM, reflect.TypeOf((*server.DepositTradeItem)(nil)), func() Protocol { return &server.DepositTradeItem{} })
	RegisterProtocol(server.RETRIEVE_TRADE_ITEM, reflect.TypeOf((*server.RetrieveTradeItem)(nil)), func() Protocol { return &server.RetrieveTradeItem{} })
	RegisterProtocol(server.USE_ITEM, reflect.TypeOf((*server.UseItem)(nil)), func() Protocol { return &server.UseItem{} })
	RegisterProtocol(server.DROP_ITEM, reflect.TypeOf((*server.DropItem)(nil)), func() Protocol { return &server.DropItem{} })
	RegisterProtocol(server.PLAYER_UPDATE, reflect.TypeOf((*server.PlayerUpdate)(nil)), func() Protocol { return &server.PlayerUpdate{} })
	RegisterProtocol(server.PLAYER_INSPECT, reflect.TypeOf((*server.PlayerInspect)(nil)), func() Protocol { return &server.PlayerInspect{} })
	RegisterProtocol(server.LOG_OUT_SUCCESS, reflect.TypeOf((*server.LogOutSuccess)(nil)), func() Protocol { return &server.LogOutSuccess{} })
	RegisterProtocol(server.LOG_OUT_FAILED, reflect.TypeOf((*server.LogOutFailed)(nil)), func() Protocol { return &server.LogOutFailed{} })
	RegisterProtocol(server.TIME_OF_DAY, reflect.TypeOf((*server.TimeOfDay)(nil)), func() Protocol { return &server.TimeOfDay{} })
	RegisterProtocol(server.CHANGE_A_MODE, reflect.TypeOf((*server.ChangeAMode)(nil)), func() Protocol { return &server.ChangeAMode{} })
	RegisterProtocol(server.CHANGE_P_MODE, reflect.TypeOf((*server.ChangePMode)(nil)), func() Protocol { return &server.ChangePMode{} })
	RegisterProtocol(server.OBJECT_ITEM, reflect.TypeOf((*server.ObjectItem)(nil)), func() Protocol { return &server.ObjectItem{} })
	RegisterProtocol(server.OBJECT_GOLD, reflect.TypeOf((*server.ObjectGold)(nil)), func() Protocol { return &server.ObjectGold{} })
	RegisterProtocol(server.GAINED_ITEM, reflect.TypeOf((*server.GainedItem)(nil)), func() Protocol { return &server.GainedItem{} })
	RegisterProtocol(server.GAINED_GOLD, reflect.TypeOf((*server.GainedGold)(nil)), func() Protocol { return &server.GainedGold{} })
	RegisterProtocol(server.LOSE_GOLD, reflect.TypeOf((*server.LoseGold)(nil)), func() Protocol { return &server.LoseGold{} })
	RegisterProtocol(server.GAINED_CREDIT, reflect.TypeOf((*server.GainedCredit)(nil)), func() Protocol { return &server.GainedCredit{} })
	RegisterProtocol(server.LOSE_CREDIT, reflect.TypeOf((*server.LoseCredit)(nil)), func() Protocol { return &server.LoseCredit{} })
	RegisterProtocol(server.OBJECT_MONSTER, reflect.TypeOf((*server.ObjectMonster)(nil)), func() Protocol { return &server.ObjectMonster{} })
	RegisterProtocol(server.OBJECT_ATTACK, reflect.TypeOf((*server.ObjectAttack)(nil)), func() Protocol { return &server.ObjectAttack{} })
	RegisterProtocol(server.STRUCK, reflect.TypeOf((*server.Struck)(nil)), func() Protocol { return &server.Struck{} })
	RegisterProtocol(server.OBJECT_STRUCK, reflect.TypeOf((*server.ObjectStruck)(nil)), func() Protocol { return &server.ObjectStruck{} })
	RegisterProtocol(server.DAMAGE_INDICATOR, reflect.TypeOf((*server.DamageIndicator)(nil)), func() Protocol { return &server.DamageIndicator{} })
	RegisterProtocol(server.DURA_CHANGED, reflect.TypeOf((*server.DuraChanged)(nil)), func() Protocol { return &server.DuraChanged{} })
	RegisterProtocol(server.HEALTH_CHANGED, reflect.TypeOf((*server.HealthChanged)(nil)), func() Protocol { return &server.HealthChanged{} })
	RegisterProtocol(server.DELETE_ITEM, reflect.TypeOf((*server.DeleteItem)(nil)), func() Protocol { return &server.DeleteItem{} })
	RegisterProtocol(server.DEATH, reflect.TypeOf((*server.Death)(nil)), func() Protocol { return &server.Death{} })
	RegisterProtocol(server.OBJECT_DIED, reflect.TypeOf((*server.ObjectDied)(nil)), func() Protocol { return &server.ObjectDied{} })
	RegisterProtocol(server.COLOUR_CHANGED, reflect.TypeOf((*server.ColourChanged)(nil)), func() Protocol { return &server.ColourChanged{} })
	RegisterProtocol(server.OBJECT_COLOUR_CHANGED, reflect.TypeOf((*server.ObjectColourChanged)(nil)), func() Protocol { return &server.ObjectColourChanged{} })
	RegisterProtocol(server.OBJECT_GUILD_NAME_CHANGED, reflect.TypeOf((*server.ObjectGuildNameChanged)(nil)), func() Protocol { return &server.ObjectGuildNameChanged{} })
	RegisterProtocol(server.GAIN_EXPERIENCE, reflect.TypeOf((*server.GainExperience)(nil)), func() Protocol { return &server.GainExperience{} })
	RegisterProtocol(server.LEVEL_CHANGED, reflect.TypeOf((*server.LevelChanged)(nil)), func() Protocol { return &server.LevelChanged{} })
	RegisterProtocol(server.OBJECT_LEVELED, reflect.TypeOf((*server.ObjectLeveled)(nil)), func() Protocol { return &server.ObjectLeveled{} })
	RegisterProtocol(server.OBJECT_HARVEST, reflect.TypeOf((*server.ObjectHarvest)(nil)), func() Protocol { return &server.ObjectHarvest{} })
	RegisterProtocol(server.OBJECT_HARVESTED, reflect.TypeOf((*server.ObjectHarvested)(nil)), func() Protocol { return &server.ObjectHarvested{} })
	RegisterProtocol(server.OBJECT_NPC, reflect.TypeOf((*server.ObjectNPC)(nil)), func() Protocol { return &server.ObjectNPC{} })
	RegisterProtocol(server.NPC_RESPONSE, reflect.TypeOf((*server.NPCResponse)(nil)), func() Protocol { return &server.NPCResponse{} })
	RegisterProtocol(server.OBJECT_HIDE, reflect.TypeOf((*server.ObjectHide)(nil)), func() Protocol { return &server.ObjectHide{} })
	RegisterProtocol(server.OBJECT_SHOW, reflect.TypeOf((*server.ObjectShow)(nil)), func() Protocol { return &server.ObjectShow{} })
	RegisterProtocol(server.POISONED, reflect.TypeOf((*server.Poisoned)(nil)), func() Protocol { return &server.Poisoned{} })
	RegisterProtocol(server.OBJECT_POISONED, reflect.TypeOf((*server.ObjectPoisoned)(nil)), func() Protocol { return &server.ObjectPoisoned{} })
	RegisterProtocol(server.MAP_CHANGED, reflect.TypeOf((*server.MapChanged)(nil)), func() Protocol { return &server.MapChanged{} })
	RegisterProtocol(server.OBJECT_TELEPORT_OUT, reflect.TypeOf((*server.ObjectTeleportOut)(nil)), func() Protocol { return &server.ObjectTeleportOut{} })
	RegisterProtocol(server.OBJECT_TELEPORT_IN, reflect.TypeOf((*server.ObjectTeleportIn)(nil)), func() Protocol { return &server.ObjectTeleportIn{} })
	RegisterProtocol(server.TELEPORT_IN, reflect.TypeOf((*server.TeleportIn)(nil)), func() Protocol { return &server.TeleportIn{} })
	RegisterProtocol(server.NPC_GOODS, reflect.TypeOf((*server.NPCGoods)(nil)), func() Protocol { return &server.NPCGoods{} })
	RegisterProtocol(server.NPC_SELL, reflect.TypeOf((*server.NPCSell)(nil)), func() Protocol { return &server.NPCSell{} })
	RegisterProtocol(server.NPC_REPAIR, reflect.TypeOf((*server.NPCRepair)(nil)), func() Protocol { return &server.NPCRepair{} })
	RegisterProtocol(server.NPC_S_REPAIR, reflect.TypeOf((*server.NPCSRepair)(nil)), func() Protocol { return &server.NPCSRepair{} })
	RegisterProtocol(server.NPC_REFINE, reflect.TypeOf((*server.NPCRefine)(nil)), func() Protocol { return &server.NPCRefine{} })
	RegisterProtocol(server.NPC_CHECK_REFINE, reflect.TypeOf((*server.NPCCheckRefine)(nil)), func() Protocol { return &server.NPCCheckRefine{} })
	RegisterProtocol(server.NPC_COLLECT_REFINE, reflect.TypeOf((*server.NPCCollectRefine)(nil)), func() Protocol { return &server.NPCCollectRefine{} })
	RegisterProtocol(server.NPC_REPLACE_WED_RING, reflect.TypeOf((*server.NPCReplaceWedRing)(nil)), func() Protocol { return &server.NPCReplaceWedRing{} })
	RegisterProtocol(server.NPC_STORAGE, reflect.TypeOf((*server.NPCStorage)(nil)), func() Protocol { return &server.NPCStorage{} })
	RegisterProtocol(server.SELL_ITEM, reflect.TypeOf((*server.SellItem)(nil)), func() Protocol { return &server.SellItem{} })
	RegisterProtocol(server.CRAFT_ITEM, reflect.TypeOf((*server.CraftItem)(nil)), func() Protocol { return &server.CraftItem{} })
	RegisterProtocol(server.REPAIR_ITEM, reflect.TypeOf((*server.RepairItem)(nil)), func() Protocol { return &server.RepairItem{} })
	RegisterProtocol(server.ITEM_REPAIRED, reflect.TypeOf((*server.ItemRepaired)(nil)), func() Protocol { return &server.ItemRepaired{} })
	RegisterProtocol(server.NEW_MAGIC, reflect.TypeOf((*server.NewMagic)(nil)), func() Protocol { return &server.NewMagic{} })
	RegisterProtocol(server.REMOVE_MAGIC, reflect.TypeOf((*server.RemoveMagic)(nil)), func() Protocol { return &server.RemoveMagic{} })
	RegisterProtocol(server.MAGIC_LEVELED, reflect.TypeOf((*server.MagicLeveled)(nil)), func() Protocol { return &server.MagicLeveled{} })
	RegisterProtocol(server.MAGIC, reflect.TypeOf((*server.Magic)(nil)), func() Protocol { return &server.Magic{} })
	RegisterProtocol(server.MAGIC_DELAY, reflect.TypeOf((*server.MagicDelay)(nil)), func() Protocol { return &server.MagicDelay{} })
	RegisterProtocol(server.MAGIC_CAST, reflect.TypeOf((*server.MagicCast)(nil)), func() Protocol { return &server.MagicCast{} })
	RegisterProtocol(server.OBJECT_MAGIC, reflect.TypeOf((*server.ObjectMagic)(nil)), func() Protocol { return &server.ObjectMagic{} })
	RegisterProtocol(server.OBJECT_EFFECT, reflect.TypeOf((*server.ObjectEffect)(nil)), func() Protocol { return &server.ObjectEffect{} })
	RegisterProtocol(server.RANGE_ATTACK, reflect.TypeOf((*server.RangeAttack)(nil)), func() Protocol { return &server.RangeAttack{} })
	RegisterProtocol(server.PUSHED, reflect.TypeOf((*server.Pushed)(nil)), func() Protocol { return &server.Pushed{} })
	RegisterProtocol(server.OBJECT_PUSHED, reflect.TypeOf((*server.ObjectPushed)(nil)), func() Protocol { return &server.ObjectPushed{} })
	RegisterProtocol(server.OBJECT_NAME, reflect.TypeOf((*server.ObjectName)(nil)), func() Protocol { return &server.ObjectName{} })
	RegisterProtocol(server.USER_STORAGE, reflect.TypeOf((*server.UserStorage)(nil)), func() Protocol { return &server.UserStorage{} })
	RegisterProtocol(server.SWITCH_GROUP, reflect.TypeOf((*server.SwitchGroup)(nil)), func() Protocol { return &server.SwitchGroup{} })
	RegisterProtocol(server.DELETE_GROUP, reflect.TypeOf((*server.DeleteGroup)(nil)), func() Protocol { return &server.DeleteGroup{} })
	RegisterProtocol(server.DELETE_MEMBER, reflect.TypeOf((*server.DeleteMember)(nil)), func() Protocol { return &server.DeleteMember{} })
	RegisterProtocol(server.GROUP_INVITE, reflect.TypeOf((*server.GroupInvite)(nil)), func() Protocol { return &server.GroupInvite{} })
	RegisterProtocol(server.ADD_MEMBER, reflect.TypeOf((*server.AddMember)(nil)), func() Protocol { return &server.AddMember{} })
	RegisterProtocol(server.REVIVED, reflect.TypeOf((*server.Revived)(nil)), func() Protocol { return &server.Revived{} })
	RegisterProtocol(server.OBJECT_REVIVED, reflect.TypeOf((*server.ObjectRevived)(nil)), func() Protocol { return &server.ObjectRevived{} })
	RegisterProtocol(server.SPELL_TOGGLE, reflect.TypeOf((*server.SpellToggle)(nil)), func() Protocol { return &server.SpellToggle{} })
	RegisterProtocol(server.OBJECT_HEALTH, reflect.TypeOf((*server.ObjectHealth)(nil)), func() Protocol { return &server.ObjectHealth{} })
	RegisterProtocol(server.MAP_EFFECT, reflect.TypeOf((*server.MapEffect)(nil)), func() Protocol { return &server.MapEffect{} })
	RegisterProtocol(server.OBJECT_RANGE_ATTACK, reflect.TypeOf((*server.ObjectRangeAttack)(nil)), func() Protocol { return &server.ObjectRangeAttack{} })
	RegisterProtocol(server.ADD_BUFF, reflect.TypeOf((*server.AddBuff)(nil)), func() Protocol { return &server.AddBuff{} })
	RegisterProtocol(server.REMOVE_BUFF, reflect.TypeOf((*server.RemoveBuff)(nil)), func() Protocol { return &server.RemoveBuff{} })
	RegisterProtocol(server.OBJECT_HIDDEN, reflect.TypeOf((*server.ObjectHidden)(nil)), func() Protocol { return &server.ObjectHidden{} })
	RegisterProtocol(server.REFRESH_ITEM, reflect.TypeOf((*server.RefreshItem)(nil)), func() Protocol { return &server.RefreshItem{} })
	RegisterProtocol(server.OBJECT_SPELL, reflect.TypeOf((*server.ObjectSpell)(nil)), func() Protocol { return &server.ObjectSpell{} })
	RegisterProtocol(server.USER_DASH, reflect.TypeOf((*server.UserDash)(nil)), func() Protocol { return &server.UserDash{} })
	RegisterProtocol(server.OBJECT_DASH, reflect.TypeOf((*server.ObjectDash)(nil)), func() Protocol { return &server.ObjectDash{} })
	RegisterProtocol(server.USER_DASH_FAIL, reflect.TypeOf((*server.UserDashFail)(nil)), func() Protocol { return &server.UserDashFail{} })
	RegisterProtocol(server.OBJECT_DASH_FAIL, reflect.TypeOf((*server.ObjectDashFail)(nil)), func() Protocol { return &server.ObjectDashFail{} })
	RegisterProtocol(server.NPC_CONSIGN, reflect.TypeOf((*server.NPCConsign)(nil)), func() Protocol { return &server.NPCConsign{} })
	RegisterProtocol(server.NPC_MARKET, reflect.TypeOf((*server.NPCMarket)(nil)), func() Protocol { return &server.NPCMarket{} })
	RegisterProtocol(server.NPC_MARKET_PAGE, reflect.TypeOf((*server.NPCMarketPage)(nil)), func() Protocol { return &server.NPCMarketPage{} })
	RegisterProtocol(server.CONSIGN_ITEM, reflect.TypeOf((*server.ConsignItem)(nil)), func() Protocol { return &server.ConsignItem{} })
	RegisterProtocol(server.MARKET_FAIL, reflect.TypeOf((*server.MarketFail)(nil)), func() Protocol { return &server.MarketFail{} })
	RegisterProtocol(server.MARKET_SUCCESS, reflect.TypeOf((*server.MarketSuccess)(nil)), func() Protocol { return &server.MarketSuccess{} })
	RegisterProtocol(server.OBJECT_SIT_DOWN, reflect.TypeOf((*server.ObjectSitDown)(nil)), func() Protocol { return &server.ObjectSitDown{} })
	RegisterProtocol(server.IN_TRAP_ROCK, reflect.TypeOf((*server.InTrapRock)(nil)), func() Protocol { return &server.InTrapRock{} })
	RegisterProtocol(server.BASE_STATS_INFO, reflect.TypeOf((*server.BaseStatsInfo)(nil)), func() Protocol { return &server.BaseStatsInfo{} })
	RegisterProtocol(server.USER_NAME, reflect.TypeOf((*server.UserName)(nil)), func() Protocol { return &server.UserName{} })
	RegisterProtocol(server.CHAT_ITEM_STATS, reflect.TypeOf((*server.ChatItemStats)(nil)), func() Protocol { return &server.ChatItemStats{} })
	RegisterProtocol(server.GUILD_NOTICE_CHANGE, reflect.TypeOf((*server.GuildNoticeChange)(nil)), func() Protocol { return &server.GuildNoticeChange{} })
	RegisterProtocol(server.GUILD_MEMBER_CHANGE, reflect.TypeOf((*server.GuildMemberChange)(nil)), func() Protocol { return &server.GuildMemberChange{} })
	RegisterProtocol(server.GUILD_STATUS, reflect.TypeOf((*server.GuildStatus)(nil)), func() Protocol { return &server.GuildStatus{} })
	RegisterProtocol(server.GUILD_INVITE, reflect.TypeOf((*server.GuildInvite)(nil)), func() Protocol { return &server.GuildInvite{} })
	RegisterProtocol(server.GUILD_EXP_GAIN, reflect.TypeOf((*server.GuildExpGain)(nil)), func() Protocol { return &server.GuildExpGain{} })
	RegisterProtocol(server.GUILD_NAME_REQUEST, reflect.TypeOf((*server.GuildNameRequest)(nil)), func() Protocol { return &server.GuildNameRequest{} })
	RegisterProtocol(server.GUILD_STORAGE_GOLD_CHANGE, reflect.TypeOf((*server.GuildStorageGoldChange)(nil)), func() Protocol { return &server.GuildStorageGoldChange{} })
	RegisterProtocol(server.GUILD_STORAGE_ITEM_CHANGE, reflect.TypeOf((*server.GuildStorageItemChange)(nil)), func() Protocol { return &server.GuildStorageItemChange{} })
	RegisterProtocol(server.GUILD_STORAGE_LIST, reflect.TypeOf((*server.GuildStorageList)(nil)), func() Protocol { return &server.GuildStorageList{} })
	RegisterProtocol(server.GUILD_REQUEST_WAR, reflect.TypeOf((*server.GuildRequestWar)(nil)), func() Protocol { return &server.GuildRequestWar{} })
	RegisterProtocol(server.DEFAULT_NPC, reflect.TypeOf((*server.DefaultNPC)(nil)), func() Protocol { return &server.DefaultNPC{} })
	RegisterProtocol(server.NPC_UPDATE, reflect.TypeOf((*server.NPCUpdate)(nil)), func() Protocol { return &server.NPCUpdate{} })
	RegisterProtocol(server.NPC_IMAGE_UPDATE, reflect.TypeOf((*server.NPCImageUpdate)(nil)), func() Protocol { return &server.NPCImageUpdate{} })
	RegisterProtocol(server.MARRIAGE_REQUEST, reflect.TypeOf((*server.MarriageRequest)(nil)), func() Protocol { return &server.MarriageRequest{} })
	RegisterProtocol(server.DIVORCE_REQUEST, reflect.TypeOf((*server.DivorceRequest)(nil)), func() Protocol { return &server.DivorceRequest{} })
	RegisterProtocol(server.MENTOR_REQUEST, reflect.TypeOf((*server.MentorRequest)(nil)), func() Protocol { return &server.MentorRequest{} })
	RegisterProtocol(server.TRADE_REQUEST, reflect.TypeOf((*server.TradeRequest)(nil)), func() Protocol { return &server.TradeRequest{} })
	RegisterProtocol(server.TRADE_ACCEPT, reflect.TypeOf((*server.TradeAccept)(nil)), func() Protocol { return &server.TradeAccept{} })
	RegisterProtocol(server.TRADE_GOLD, reflect.TypeOf((*server.TradeGold)(nil)), func() Protocol { return &server.TradeGold{} })
	RegisterProtocol(server.TRADE_ITEM, reflect.TypeOf((*server.TradeItem)(nil)), func() Protocol { return &server.TradeItem{} })
	RegisterProtocol(server.TRADE_CONFIRM, reflect.TypeOf((*server.TradeConfirm)(nil)), func() Protocol { return &server.TradeConfirm{} })
	RegisterProtocol(server.TRADE_CANCEL, reflect.TypeOf((*server.TradeCancel)(nil)), func() Protocol { return &server.TradeCancel{} })
	RegisterProtocol(server.MOUNT_UPDATE, reflect.TypeOf((*server.MountUpdate)(nil)), func() Protocol { return &server.MountUpdate{} })
	RegisterProtocol(server.EQUIP_SLOT_ITEM, reflect.TypeOf((*server.EquipSlotItem)(nil)), func() Protocol { return &server.EquipSlotItem{} })
	RegisterProtocol(server.FISHING_UPDATE, reflect.TypeOf((*server.FishingUpdate)(nil)), func() Protocol { return &server.FishingUpdate{} })
	RegisterProtocol(server.CHANGE_QUEST, reflect.TypeOf((*server.ChangeQuest)(nil)), func() Protocol { return &server.ChangeQuest{} })
	RegisterProtocol(server.COMPLETE_QUEST, reflect.TypeOf((*server.CompleteQuest)(nil)), func() Protocol { return &server.CompleteQuest{} })
	RegisterProtocol(server.SHARE_QUEST, reflect.TypeOf((*server.ShareQuest)(nil)), func() Protocol { return &server.ShareQuest{} })
	RegisterProtocol(server.NEW_QUEST_INFO, reflect.TypeOf((*server.NewQuestInfo)(nil)), func() Protocol { return &server.NewQuestInfo{} })
	RegisterProtocol(server.GAINED_QUEST_ITEM, reflect.TypeOf((*server.GainedQuestItem)(nil)), func() Protocol { return &server.GainedQuestItem{} })
	RegisterProtocol(server.DELETE_QUEST_ITEM, reflect.TypeOf((*server.DeleteQuestItem)(nil)), func() Protocol { return &server.DeleteQuestItem{} })
	RegisterProtocol(server.CANCEL_REINCARNATION, reflect.TypeOf((*server.CancelReincarnation)(nil)), func() Protocol { return &server.CancelReincarnation{} })
	RegisterProtocol(server.REQUEST_REINCARNATION, reflect.TypeOf((*server.RequestReincarnation)(nil)), func() Protocol { return &server.RequestReincarnation{} })
	RegisterProtocol(server.USER_BACK_STEP, reflect.TypeOf((*server.UserBackStep)(nil)), func() Protocol { return &server.UserBackStep{} })
	RegisterProtocol(server.OBJECT_BACK_STEP, reflect.TypeOf((*server.ObjectBackStep)(nil)), func() Protocol { return &server.ObjectBackStep{} })
	RegisterProtocol(server.USER_DASH_ATTACK, reflect.TypeOf((*server.UserDashAttack)(nil)), func() Protocol { return &server.UserDashAttack{} })
	RegisterProtocol(server.OBJECT_DASH_ATTACK, reflect.TypeOf((*server.ObjectDashAttack)(nil)), func() Protocol { return &server.ObjectDashAttack{} })
	RegisterProtocol(server.USER_ATTACK_MOVE, reflect.TypeOf((*server.UserAttackMove)(nil)), func() Protocol { return &server.UserAttackMove{} })
	RegisterProtocol(server.COMBINE_ITEM, reflect.TypeOf((*server.CombineItem)(nil)), func() Protocol { return &server.CombineItem{} })
	RegisterProtocol(server.ITEM_UPGRADED, reflect.TypeOf((*server.ItemUpgraded)(nil)), func() Protocol { return &server.ItemUpgraded{} })
	RegisterProtocol(server.SET_CONCENTRATION, reflect.TypeOf((*server.SetConcentration)(nil)), func() Protocol { return &server.SetConcentration{} })
	RegisterProtocol(server.SET_OBJECT_CONCENTRATION, reflect.TypeOf((*server.SetObjectConcentration)(nil)), func() Protocol { return &server.SetObjectConcentration{} })
	RegisterProtocol(server.SET_ELEMENTAL, reflect.TypeOf((*server.SetElemental)(nil)), func() Protocol { return &server.SetElemental{} })
	RegisterProtocol(server.SET_OBJECT_ELEMENTAL, reflect.TypeOf((*server.SetObjectElemental)(nil)), func() Protocol { return &server.SetObjectElemental{} })
	RegisterProtocol(server.REMOVE_DELAYED_EXPLOSION, reflect.TypeOf((*server.RemoveDelayedExplosion)(nil)), func() Protocol { return &server.RemoveDelayedExplosion{} })
	RegisterProtocol(server.OBJECT_DECO, reflect.TypeOf((*server.ObjectDeco)(nil)), func() Protocol { return &server.ObjectDeco{} })
	RegisterProtocol(server.OBJECT_SNEAKING, reflect.TypeOf((*server.ObjectSneaking)(nil)), func() Protocol { return &server.ObjectSneaking{} })
	RegisterProtocol(server.OBJECT_LEVEL_EFFECTS, reflect.TypeOf((*server.ObjectLevelEffects)(nil)), func() Protocol { return &server.ObjectLevelEffects{} })
	RegisterProtocol(server.SET_BINDING_SHOT, reflect.TypeOf((*server.SetBindingShot)(nil)), func() Protocol { return &server.SetBindingShot{} })
	RegisterProtocol(server.SEND_OUTPUT_MESSAGE, reflect.TypeOf((*server.SendOutputMessage)(nil)), func() Protocol { return &server.SendOutputMessage{} })
	RegisterProtocol(server.NPC_AWAKENING, reflect.TypeOf((*server.NPCAwakening)(nil)), func() Protocol { return &server.NPCAwakening{} })
	RegisterProtocol(server.NPC_DISASSEMBLE, reflect.TypeOf((*server.NPCDisassemble)(nil)), func() Protocol { return &server.NPCDisassemble{} })
	RegisterProtocol(server.NPC_DOWNGRADE, reflect.TypeOf((*server.NPCDowngrade)(nil)), func() Protocol { return &server.NPCDowngrade{} })
	RegisterProtocol(server.NPC_RESET, reflect.TypeOf((*server.NPCReset)(nil)), func() Protocol { return &server.NPCReset{} })
	RegisterProtocol(server.AWAKENING_NEED_MATERIALS, reflect.TypeOf((*server.AwakeningNeedMaterials)(nil)), func() Protocol { return &server.AwakeningNeedMaterials{} })
	RegisterProtocol(server.AWAKENING_LOCKED_ITEM, reflect.TypeOf((*server.AwakeningLockedItem)(nil)), func() Protocol { return &server.AwakeningLockedItem{} })
	RegisterProtocol(server.AWAKENING, reflect.TypeOf((*server.Awakening)(nil)), func() Protocol { return &server.Awakening{} })
	RegisterProtocol(server.RECEIVE_MAIL, reflect.TypeOf((*server.ReceiveMail)(nil)), func() Protocol { return &server.ReceiveMail{} })
	RegisterProtocol(server.MAIL_LOCKED_ITEM, reflect.TypeOf((*server.MailLockedItem)(nil)), func() Protocol { return &server.MailLockedItem{} })
	RegisterProtocol(server.MAIL_SEND_REQUEST, reflect.TypeOf((*server.MailSendRequest)(nil)), func() Protocol { return &server.MailSendRequest{} })
	RegisterProtocol(server.MAIL_SENT, reflect.TypeOf((*server.MailSent)(nil)), func() Protocol { return &server.MailSent{} })
	RegisterProtocol(server.PARCEL_COLLECTED, reflect.TypeOf((*server.ParcelCollected)(nil)), func() Protocol { return &server.ParcelCollected{} })
	RegisterProtocol(server.MAIL_COST, reflect.TypeOf((*server.MailCost)(nil)), func() Protocol { return &server.MailCost{} })
	RegisterProtocol(server.RESIZE_INVENTORY, reflect.TypeOf((*server.ResizeInventory)(nil)), func() Protocol { return &server.ResizeInventory{} })
	RegisterProtocol(server.RESIZE_STORAGE, reflect.TypeOf((*server.ResizeStorage)(nil)), func() Protocol { return &server.ResizeStorage{} })
	RegisterProtocol(server.NEW_INTELLIGENT_CREATURE, reflect.TypeOf((*server.NewIntelligentCreature)(nil)), func() Protocol { return &server.NewIntelligentCreature{} })
	RegisterProtocol(server.UPDATE_INTELLIGENT_CREATURElIST, reflect.TypeOf((*server.UpdateIntelligentCreatureList)(nil)), func() Protocol { return &server.UpdateIntelligentCreatureList{} })
	RegisterProtocol(server.INTELLIGENT_CREATURE_ENABLE_RENAME, reflect.TypeOf((*server.IntelligentCreatureEnableRename)(nil)), func() Protocol { return &server.IntelligentCreatureEnableRename{} })
	RegisterProtocol(server.INTELLIGENT_CREATURE_PICKUP, reflect.TypeOf((*server.IntelligentCreaturePickup)(nil)), func() Protocol { return &server.IntelligentCreaturePickup{} })
	RegisterProtocol(server.NPC_PEARL_GOODS, reflect.TypeOf((*server.NPCPearlGoods)(nil)), func() Protocol { return &server.NPCPearlGoods{} })
	RegisterProtocol(server.TRANSFORM_UPDATE, reflect.TypeOf((*server.TransformUpdate)(nil)), func() Protocol { return &server.TransformUpdate{} })
	RegisterProtocol(server.FRIEND_UPDATE, reflect.TypeOf((*server.FriendUpdate)(nil)), func() Protocol { return &server.FriendUpdate{} })
	RegisterProtocol(server.LOVER_UPDATE, reflect.TypeOf((*server.LoverUpdate)(nil)), func() Protocol { return &server.LoverUpdate{} })
	RegisterProtocol(server.MENTOR_UPDATE, reflect.TypeOf((*server.MentorUpdate)(nil)), func() Protocol { return &server.MentorUpdate{} })
	RegisterProtocol(server.GUILD_BUFF_LIST, reflect.TypeOf((*server.GuildBuffList)(nil)), func() Protocol { return &server.GuildBuffList{} })
	RegisterProtocol(server.NPC_REQUEST_INPUT, reflect.TypeOf((*server.NPCRequestInput)(nil)), func() Protocol { return &server.NPCRequestInput{} })
	RegisterProtocol(server.GAME_SHOP_INFO, reflect.TypeOf((*server.GameShopInfo)(nil)), func() Protocol { return &server.GameShopInfo{} })
	RegisterProtocol(server.GAME_SHOP_STOCK, reflect.TypeOf((*server.GameShopStock)(nil)), func() Protocol { return &server.GameShopStock{} })
	RegisterProtocol(server.RANKINGS, reflect.TypeOf((*server.Rankings)(nil)), func() Protocol { return &server.Rankings{} })
	RegisterProtocol(server.OPENDOOR, reflect.TypeOf((*server.Opendoor)(nil)), func() Protocol { return &server.Opendoor{} })
	RegisterProtocol(server.GET_RENTED_ITEMS, reflect.TypeOf((*server.GetRentedItems)(nil)), func() Protocol { return &server.GetRentedItems{} })
	RegisterProtocol(server.ITEM_RENTAL_REQUEST, reflect.TypeOf((*server.ItemRentalRequest)(nil)), func() Protocol { return &server.ItemRentalRequest{} })
	RegisterProtocol(server.ITEM_RENTAL_FEE, reflect.TypeOf((*server.ItemRentalFee)(nil)), func() Protocol { return &server.ItemRentalFee{} })
	RegisterProtocol(server.ITEM_RENTAL_PERIOD, reflect.TypeOf((*server.ItemRentalPeriod)(nil)), func() Protocol { return &server.ItemRentalPeriod{} })
	RegisterProtocol(server.DEPOSIT_RENTAL_ITEM, reflect.TypeOf((*server.DepositRentalItem)(nil)), func() Protocol { return &server.DepositRentalItem{} })
	RegisterProtocol(server.RETRIEVE_RENTAL_ITEM, reflect.TypeOf((*server.RetrieveRentalItem)(nil)), func() Protocol { return &server.RetrieveRentalItem{} })
	RegisterProtocol(server.UPDATE_RENTAL_ITEM, reflect.TypeOf((*server.UpdateRentalItem)(nil)), func() Protocol { return &server.UpdateRentalItem{} })
	RegisterProtocol(server.CANCEL_ITEM_RENTAL, reflect.TypeOf((*server.CancelItemRental)(nil)), func() Protocol { return &server.CancelItemRental{} })
	RegisterProtocol(server.ITEM_RENTAL_LOCK, reflect.TypeOf((*server.ItemRentalLock)(nil)), func() Protocol { return &server.ItemRentalLock{} })
	RegisterProtocol(server.ITEM_RENTAL_PARTNER_LOCK, reflect.TypeOf((*server.ItemRentalPartnerLock)(nil)), func() Protocol { return &server.ItemRentalPartnerLock{} })
	RegisterProtocol(server.CAN_CONFIRM_ITEM_RENTAL, reflect.TypeOf((*server.CanConfirmItemRental)(nil)), func() Protocol { return &server.CanConfirmItemRental{} })
	RegisterProtocol(server.CONFIRM_ITEM_RENTAL, reflect.TypeOf((*server.ConfirmItemRental)(nil)), func() Protocol { return &server.ConfirmItemRental{} })
	RegisterProtocol(server.NEW_RECIPE_INFO, reflect.TypeOf((*server.NewRecipeInfo)(nil)), func() Protocol { return &server.NewRecipeInfo{} })
	RegisterProtocol(server.OPEN_BROWSER, reflect.TypeOf((*server.OpenBrowser)(nil)), func() Protocol { return &server.OpenBrowser{} })
}
